<template>
	<!-- 表格 -->
	<el-table class="pageTableClass" :data="taskNoPage" height="calc(100vh - 380px)" :loading="isLoading">
		<el-table-column label="序号" align="center" width="70">
			<template #default="scope">
				{{ (paginationParams.current - 1) * paginationParams.pageSize + scope.$index + 1 }}
			</template>
		</el-table-column>
		<el-table-column prop="code" min-width="150" label="计划编号" align="center" />
		<el-table-column prop="activeLine" min-width="180" label="触发时间" align="center" />
		<el-table-column prop="actualTimeCost" min-width="150" label="实际用时" align="center" />
		<el-table-column prop="equipmentName" min-width="200" label="设备名称" align="center" />
		<el-table-column prop="deadLine" min-width="180" label="截止时间" align="center" />
		<el-table-column prop="planTimeCost" min-width="100" label="计划用时" align="center" />
		<el-table-column prop="createName" min-width="180" label="创建人" align="center" />
		<el-table-column prop="teamLeaderName" min-width="180" label="班组长" align="center" />
<!--		<el-table-column prop="type" min-width="180" label="类型" align="center">-->
<!--			<template #default="scope">-->
<!--				{{ types?.find(i => i.value === scope.row.type)?.label }}-->
<!--			</template>-->
<!--		</el-table-column>-->
		<el-table-column label="操作" align="center" fixed="right" width="100">
			<template #default="scope">

				<el-button style="color:#4160beed" :icon="Tickets" text @click="handleDetails(scope.row)" size="small"
									 plain>详情
				</el-button>
			</template>
		</el-table-column>
	</el-table>
	<div class="pagePagination">
		<el-pagination background v-model:current-page="paginationParams.current"
									 v-model:page-size="paginationParams.pageSize" layout="total, sizes, prev, pager, next"
									 :total="pageTotal"
									 @size-change="handleSizeChange" @current-change="handleCurrentChange" />
	</div>
	<!-- 弹框 -->
	<el-dialog v-model="dialogVisible" title="任务详情" width="60%">
		<el-table class="pageTableClass" :data="contentDialog">
			<el-table-column prop="content" min-width="150" label="点检内容" align="center" />
			<el-table-column prop="result" min-width="200" label="结果" align="center" />
			<el-table-column prop="describe" min-width="200" label="原因描述" align="center" />
		</el-table>
		<template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false">关闭</el-button>
            </span>
		</template>
	</el-dialog>
</template>

<script setup>
import { defineProps, ref, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { Tickets } from '@element-plus/icons-vue';

const dialogVisible = ref(false);
const contentDialog = ref([]);
const types = ref([
	{
		label: '设备',
		value: 1
	},
	{
		label: '工装',
		value: 2
	}

]);
const props = defineProps({
	paginationParams: Object,
	onSubmit: Function,
	handleSizeChange: Function,
	handleCurrentChange: Function,
	taskNoPage: Array,
	pageTotal: Number,
	equipmentData: Object,
	fetchPage: Function
});

const handleDetails = (row) => {
	contentDialog.value = JSON.parse(row?.result)?.map(item => ({
		content: item?.content,
		result: item?.result,
		describe: item?.describe
	})) || [];
	dialogVisible.value = true;
};
</script>

<style scoped>
.pageTableClass {
	width: 100%;
}

.pagePagination {
	margin-top: 20px;
	text-align: center;
}
</style>